<%@include file="includes/jspf/header.jspf" %>
<%@page import="wap.rockvilletech.util.*" %>
<%
	String strCatId = request.getParameter("catID").toString();
	String SoF = "";
	String redirect_url = "";
	try {
	    strWidth=request.getParameter("w").toString();
	    strHeight=request.getParameter("h").toString();
	    SoF=request.getParameter("sof").toString();
	}
	catch(Exception ex) {
	    redirect_url = context_Path+"index.jsp";
	    response.sendRedirect(redirect_url);
	}

    int intBlockLength = 5, intRecordsToBeDisplayed = 0, intRecordsToBeFetched = 0, intCountTotal = 0, intPageID = 0, intLastPage = 0;
	String strPagingLinks = "", pid = "";
	boolean computePaging = false, isNext = true;
	pid = request.getParameter("pid") != null ? request.getParameter("pid").toString() : "0";
    Vector vUCard = ugb.getCardContent(pid, strCatId);
    if(!vUCard.isEmpty()){
    intCountTotal=(Integer)vUCard.get(0);
    intRecordsToBeDisplayed=intRecordsToBeFetched=(Integer)(vUCard.get(1));
	try {
		intLastPage = intCountTotal / intRecordsToBeDisplayed;
		intPageID = Integer.parseInt(pid.toString());
		if (intPageID > intLastPage) {
	        intPageID = intLastPage;
	    }
		if(intCountTotal == (int)(intRecordsToBeDisplayed*(intPageID+1))) intLastPage--;
    } catch(NumberFormatException ex){
    }

    if (vUCard.size()-1 < intRecordsToBeFetched) {
		intRecordsToBeDisplayed -= (intRecordsToBeFetched - vUCard.size());
		intRecordsToBeFetched = vUCard.size();
		isNext = false;
	}

	computePaging = intCountTotal >intRecordsToBeDisplayed;
   	if(computePaging){
		Paging.computePaging(request, "cardContent.jsp?",intRecordsToBeFetched, intRecordsToBeDisplayed, intCountTotal, 
				intBlockLength, intLastPage, intPageID, isNext);
		strPagingLinks = Paging.getPagingLinks();
	}
    }//end vector if

%>
        
        
        <div align="center">
            <p class="txt">Please Select a UGreeting card </p>

        <%

        if(!vUCard.isEmpty()&&vUCard.size()>2){//SeqID,ContentImage,ContentId
        for (int i=2;i<vUCard.size();i++) {
            String[] arr_card = (String[])vUCard.get(i);
        %>
        <div class="imgPlaceHolder" style="padding-bottom: 10px;">
            <a href="ucard.jsp?img=<%=arr_card[1]%>&h=<%=strHeight%>&w=<%=strWidth%>&cid=<%=arr_card[2]%>&sof=<%=SoF%>">
                <img src="<%=context_Path%>/renderImage?img=<%=arr_card[1]%>&h=<%=strHeight%>&cid=<%=arr_card[2]%>&s=0&repo=&w=<%=strWidth%>" alt="uGreetings" />
            </a>
        </div>
        <%
        }
        }else{
        out.println("Data Not Available");
        }
        %>
            <div><%=strPagingLinks%></div>
        </div>
<%@include file="includes/jspf/footer.jspf" %>
<%
ugb.LogVisit("", "cardContent", "", "", "", "","Ugreeting", request.getQueryString());
%>